<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<div class="t_bar"><span class="color_red">*</span>承担单位和合作单位分工（第一行为承担单位，合作单位最多5家） </div>
<table id="compareWork" border="0" cellspacing="0" cellpadding="0" style="width: 100%" class="table01 t_css">
    <thead>
    <tr>
        <th align="center" width="5%">选择</th>
        <th align="center" width="5%">序号</th>
        <th align="center" width="15%">单位</th>
        <th align="center" width="15%">分工</th>
    </tr>
    </thead>
    <tbody id="org_hz_tab">
    <tr style="display: none" align="center">
        <td align="center">
            <input type="radio" class="radiobutton" name="selAttendOrg11">
        </td>
        <td align="center">
            <span name="org_hzs|org_hz[0]@seq_no">[index]</span>
        </td>
        <td align="center">
            <input name="org_hzs|org_hz[0]|org_hz_name" label="单位" type="text" onchange="setCooperationUnits();" required class="input_css required maxlength:300" style="width: 80%;" maxlength="100" value="" />
        </td>

        <td align="center">
            <input name="org_hzs|org_hz[0]|divisions" label="分工" type="text" required class="input_css required maxlength:300" style="width: 80%;" maxlength="100" value="" />
        </td>



    </tr>
    <c:set value="0" var="index" scope="page" />
    <x:forEach select="$xmlData/data/org_hzs/org_hz" var="org_hz">

        <c:choose>
            <c:when test="${index<10}">
                <c:set value="0" var="flag" scope="page" />
            </c:when>
            <c:otherwise>
                <c:set value="" var="flag" scope="page" />
            </c:otherwise>
        </c:choose>
        <tr align="center">
            <td>
                <input type="radio" class="radiobutton" name="selAttendOrg11">
            </td>
            <td align="center">
					<span name="org_hzs/org_hz[${flag}${index}]@seq_no">
						<x:out select="$org_hz/@seq_no" />
					</span>
            </td>
            <td>
                <input name="org_hzs/org_hz[${flag}${index}]/org_hz_name" onchange="setCooperationUnits();" label="单位" type="text" required class="input_css required maxlength:100" style="width: 80%;" maxlength="100"
                       value="<x:out select="$org_hz/org_hz_name" />" />
            </td>

            <td align="center">

                <input name="org_hzs/org_hz[${flag}${index}]/divisions" label="分工" type="text" required class="input_css required maxlength:300" style="width: 80%;" maxlength="100"
                       value="<x:out select="$org_hz/divisions" />" />
            </td>
        </tr>
        <c:set value="${index+1}" var="index" scope="page" />
    </x:forEach>
    </tbody>
</table>
<table width="100%" class="not_table">
    <tr>
        <td>
            <input class="button_02" type="button" name="cmdAddbefore" value="添加" onclick="if(checkTabLimit('compareWork',6,'承担单位和合作单位分工最多只能填写6条')){addNewRow('compareWork');}try{top.resizeFrame();}catch(e){};" />
            <input class="button_02" name="cmdMovePrev" type="button" value="上移" onclick="movePrev('compareWork');setCooperationUnits();" />
            <input class="button_02" name="cmdMoveNext" type="button" value="下移" onclick="moveNext('compareWork');setCooperationUnits();" />
            <input class="button_02" name="cmddel" type="button" value="删除" onclick="deleteSelectedRow('compareWork','承担单位和合作单位分工');setCooperationUnits();" />
        </td>
    </tr>
</table>

<div class="t_bar"><span class="color_red required">*</span>备注（限300字）</div>
<table class="t_css" width="100%" border="0" cellspacing="0" cellpadding="0" id="tblresume">
    <tr class="li_2">
        <td>
            <textarea rows="5" style="width: 98%;" label="备注" class="input_textarea required maxlength:300" lab  name='proposal/goal/resume2'  ><x:out select="$xmlData/data/proposal/goal/resume2"/></textarea>
            <input type="hidden" name="proposal/goal/resume2_hidden" value="<x:out select="$xmlData/data/proposal/goal/resume2_hidden"/>"/>
        </td>
    </tr>

</table>

<script type="text/javascript">
    function setCooperationUnits(){
        var cooperation_units="";
        $("#compareWork tr:gt(1)").each(function(index){
            var cooperation_unit = $(this).find("td:eq(2) input").val().trim();
            var orgName = $("#org_name").val().trim();
            if(!isBlankOrNull(cooperation_unit) && cooperation_unit!=orgName){
                cooperation_units += cooperation_unit+",";
            }
        });
        if(cooperation_units!=""){
            cooperation_units=cooperation_units.substring(0,cooperation_units.length-1);
        }
        $("#cooperation_units").val(cooperation_units);
    }
    function isBlankOrNull(str){
        if(str.trim()==""){
            return true;
        }else if(str){
            return false;
        }else{
            return true;
        }
    }
</script>
